Repository navigation
csnode: fix swapped mining/staking flags on restore + warn on dropped rewards - #8
Merged
Merged
Conversation
…tings BlockChain keeps the consensus reward settings (set by special transaction order 37) so that they survive restarts through the quick-start caches. Two bugs mix up the two flags: - BlockChain::setMiningOn() writes stakingOn_, and setStakingOn() writes miningOn_. After a restart from caches (Node::init, node.cpp:195-196), Consensus::stakingOn gets the mining value and Consensus::miningOn gets the staking value. - The quick-start path emits successfullQuickStartEvent(..., miningOn_, miningOn_, ...), so Node::onSuccessQS sets stakingOn from miningOn. stakingOn and miningOn drive the block reward computed by trusted nodes (SolverCore::setBlockReward): reward split by stake, and whether a reward is written at all. A restarted node therefore computes different rewards than a node that kept running, whenever the two flags differ. On mainnet today both flags are on (block 176'776'210 distributes rewards by stake), so the bug is latent there. It becomes real as soon as order 37 switches only one of them. With both flags equal, the persisted values do not change meaning, so the fix is safe for existing caches. Test: BlockChain.MiningAndStakingSettersAreIndependent fails before the fix. nodetests: 119/119 pass. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
WalletsCache::Updater::fundConfidantsWalletsWitnReward() credits the rewards
stored in a block, but silently turns any reward above the node's local
Consensus::blockReward into 0. If a node's blockReward differs from the
network's (e.g. a consensus-settings change not applied after a restart), that
node stops crediting trusted rewards. Its balances then drift from the rest of
the network until a validator's withdrawal fails validation on it ("rejected
by graph validation", as for block 176'776'210).
Log a warning, rate-limited to one line per 10'000 drops, with the dropped
reward and the local blockReward, so operators can see this divergence instead
of only its consequences. Logging only: behaviour is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Since 5 June 2026 some nodes have been stuck at block 176'776'210 (
rejected by graph validation, thenstop block validation). Its only transaction is validator9c8VaDD6…withdrawing 57'744 CS of accumulated trusted-node rewards. On the stuck nodes that wallet holds a lower balance than on the rest of the network: node balances diverge. The exact root cause is still to be proven and needs logs from stuck nodes. This PR fixes two defects found on the reward path.1.
fix swapped mining/staking flags…(real bug, latent on mainnet today)BlockChain::setMiningOn()writesstakingOn_andsetStakingOn()writesminingOn_, so after a restart from caches the two consensus flags are swapped.miningOn_twice, sostakingOntakes the mining value.SolverCore::setBlockReward). A restarted node computes different rewards from one that kept running whenever the two flags differ.BlockChain.MiningAndStakingSettersAreIndependent: fails before the fix, passes after.2.
warn when a confidant reward is dropped…(diagnostics, behaviour unchanged)fundConfidantsWalletsWitnReward()silently turns into 0 any reward above the localConsensus::blockReward. A node whoseblockRewarddiffers from the network's stops crediting rewards, and its balances drift until a validator's withdrawal fails. The node now logs it, at most one line per 10'000 occurrences.Verification
nodetests119/119 locally (GCC 13, static Boost 1.83); CI on this PR.Upstream
Two independent commits that apply as is to CREDITSCOM/node (identical files).
🤖 Generated with Claude Code